package chapter02

object Test30_Score {
  def main(args: Array[String]): Unit = {
    val score =
      List(Map("name" -> "张三", "语文" -> 80, "数学" -> 85, "英语" -> 90),
      Map("name" -> "李四", "语文" -> 75, "数学" -> 85, "英语" -> 95),
      Map("name" -> "王五", "语文" -> 60, "数学" -> 75, "英语" -> 70))
    //计算每门课程的平局分
    var yuwen = 0
    var shuxue = 0
    var yingyu = 0
    for(i<-score){
      yuwen+=i.get("语文").head.toString.toInt
      shuxue+=i.get("数学").head.toString.toInt
      yingyu+=i.get("英语").head.toString.toInt
    }
    println("语文的平均分："+yuwen/score.size)
    println("数学的平均分："+shuxue/score.size)
    println("英语的平均分："+yingyu/score.size)
    //每个人的平均成绩
    for(i<-score){
      val i1 =
        (i.get("语文").head.toString.toInt +
          i.get("数学").head.toString.toInt +
          i.get("英语").head.toString.toInt) / 3
      println(i.get("name").head.toString+"的平均成为："+i1)
    }
  }
}
